home *** CD-ROM | disk | FTP | other *** search
- type
- cNCCanvas = class(TCanvas)
- private
- FDeviceContext: HDC;
- FWindowHandle : HWnd;
- function GetWindowRect:TRect;
- protected
- procedure CreateHandle; override;
- procedure FreeHandle;
- public
- constructor Create(aWindow: hWnd);
- destructor Destroy; override;
- property WindowRect: TRect read GetWindowRect;
- end;
-
- constructor cNCCanvas.Create(aWindow: hWnd);
- begin
- inherited Create;
- FWindowHandle:=aWindow;
- end;
-
- destructor cNCCanvas.Destroy;
- begin
- FreeHandle;
- inherited Destroy;
- end;
-
- procedure cNCCanvas.CreateHandle;
- begin
- if FWindowHandle=0 then inherited CreateHandle else
- begin
- if FDeviceContext = 0 then
- FDeviceContext := GetWindowDC(FWindowHandle);
- Handle := FDeviceContext;
- end;
- end;
-
- procedure cNCCanvas.FreeHandle;
- begin
- Handle := 0;
- if FDeviceContext <> 0 then
- begin
- ReleaseDC(FWindowHandle, FDeviceContext);
- FDeviceContext:=0;
- end;
- end;
-
- function cNCCanvas.GetWindowRect:TRect;
- begin
- winProcs.GetWindowRect(FWindowHandle,Result);
- With Result do
- begin
- Right:=Pred(Right-Left);
- Bottom:=Pred(Bottom-Top);
- Left:=0; Top:=0;
- end;
- end;
-